# -*- encoding=utf8 -*-
"""
RedFlag-TC0000109  （拍摄进入装饰页）移动文字功能
点击文字进行移动场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()

case_text = "这是一条测试数据"

log("--------------------------------点击文字进行移动场景--------------------------------------")
"""
拍摄视频进入装饰页
点击文字
输入文案
点击颜色
选择一个颜色
取消文字工具栏
截图
移动文字
截图
断言
"""

shooter.enter_photography_decoration_page()
shooter.click_element(decoration_page_text_function)
shooter.input_text_in_element(decoration_page_text_function_input, case_text)
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_choice_colour[3])
touch((0.45,0.5))
photo1 = shooter.capture_screenshot("TC0000109A.png")
shooter.swipe_screen((0.5,0.46),(0.14,0.2))
photo2 = shooter.capture_screenshot("TC0000109B.png")
shooter.assert_images_not_equal(photo1, photo2, "断言失败，截屏图片比对一致", threshold=0.98)

# 关闭应用
stop_app(UGC_package_name)